<template>
  <div class="app-container">
    <div class="top">
      <div>
        <el-button plain class="el-icon-plus" size="mini" @click="entry"
          >进场</el-button
        >
        <el-button plain class="el-icon-plus" size="mini" @click="transfer"
          >转舍</el-button
        >
        <el-button plain class="el-icon-plus" size="mini" @click="leave"
          >离场</el-button
        >
      </div>
      <el-form
        ref="form"
        :model="formData"
        label-width="80px"
        size="mini"
        inline
      >
        <el-form-item>
          <el-select v-model="formData.isPresent">
            <el-option label="全部" value=""></el-option>
            <el-option label="在场" value="在场"></el-option>
            <el-option label="离场" value="离场"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select
            v-model="formData.buildingsId"
            placeholder="所在栋舍"
            clearable
          >
            <el-option
              :label="item.name"
              :value="item.id"
              v-for="item in searchBuildList"
              :key="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-select
            v-model="formData.herdsPigsCode"
            placeholder="所在猪群"
            clearable
          >
            <el-option
              :label="item"
              :value="item"
              v-for="(item, index) in herdsPigsList"
              :key="index"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="searchPorkList">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table :data="tableList" style="width: 100%" border>
      <el-table-column
        align="center"
        :prop="item.prop"
        :label="item.label"
        v-for="(item, index) in porkTableHead"
        :key="index"
      >
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="{ row }">
          <el-button type="text" @click="deletBoar(row.id)">删除</el-button>
        </template>
      </el-table-column>
      <!-- 无数据 -->
      <template slot="empty">
        <div class="noData" v-show="tableList.length === 0">
          <img src="@/assets/images/noData.png" />
          <p>暂无数据</p>
        </div>
      </template>
    </el-table>
    <Pagination :total="total" @pagination="handlePage" :page.sync="formData.pageNum"></Pagination>

    <!-- 进场记录 -->
    <el-dialog title="登记进场" :visible.sync="entryDialog" width="700px">
      <div>
        <el-row :gutter="10">
          <el-form
            ref="entryForm"
            :model="entryForm"
            label-width="80px"
            size="mini"
            :rules="entryRules"
          >
            <el-col :span="12">
              <el-form-item label="进场日期" prop="entryDate">
                <el-date-picker
                  :picker-options="pickerOptions"
                  v-model="entryForm.entryDate"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  type="date"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="所在位置" prop="buildingsId">
                <el-select
                  v-model="entryForm.buildingsId"
                  placeholder="选择舍"
                  class="house"
                  @change="selectBuild('entry', entryForm.buildingsId)"
                >
                  <el-option
                    :label="item.name"
                    :value="item.id"
                    style="width: 80px"
                    v-for="item in buildList"
                    :key="item.id"
                  ></el-option>
                </el-select>
                <el-select
                  v-model="entryForm.columnId"
                  placeholder="栏号"
                  class="column"
                >
                  <el-option
                    :label="item.name"
                    :value="item.id"
                    v-for="item in columnList"
                    :key="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="进场类型" prop="entryType">
                <el-select v-model="entryForm.entryType" placeholder="选择类型">
                  <el-option label="购买" value="购买"></el-option>
                  <el-option label="转入" value="转入"></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="猪群编号" prop="herdsPigsCode">
                <el-autocomplete
                  class="inline-input"
                  v-model="entryForm.herdsPigsCode"
                  :fetch-suggestions="entryHerdsPigsCodeSearch"
                  placeholder="请输入猪群编号"
                ></el-autocomplete>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="出生日期" prop="birthDate">
                <el-date-picker
                  :picker-options="pickerOptions"
                  v-model="entryForm.birthDate"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  type="date"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="数量" prop="number">
                <el-input
                  v-model="entryForm.number"
                  maxlength="3"
                  placeholder="请输入进场数量"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="品种">
                <el-select v-model="entryForm.variety" placeholder="选择品种">
                  <el-option
                    :label="item.label"
                    :value="item.label"
                    v-for="item in varietyList"
                    :key="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="重量">
                <el-input v-model="entryForm.weight" placeholder="输入数字"
                  ><p slot="suffix" style="display: inline">kg</p></el-input
                >
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="价格">
                <el-input v-model="entryForm.price" placeholder="请输入总价格"
                  ><p slot="suffix" style="display: inline">元</p></el-input
                >
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="操作人员">
                <el-select v-model="entryForm.operatorsUser">
                  <el-option
                    :label="$store.state.user.userInfo.nickName"
                    :value="userId"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="备注">
                <el-input type="textarea" v-model="entryForm.remark"></el-input>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
      <div slot="footer">
        <el-button @click="entryDialog = false">取 消</el-button>
        <el-button type="primary" @click="confirm('entry')">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 转舍记录 -->
    <el-dialog title="登记转舍" :visible.sync="transferDialog" width="700px">
      <div>
        <el-row>
          <el-form
            ref="transferForm"
            label-width="80px"
            :model="transferForm"
            size="mini"
            :rules="transferRules"
            width="700px"
          >
            <el-col :span="12">
              <el-form-item label="转舍日期" prop="tdDate">
                <el-date-picker
                  value-format="yyyy-MM-dd HH:mm:ss"
                  v-model="transferForm.tdDate"
                  type="date"
                  placeholder="选择日期"
                  :picker-options="pickerOptions"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="数量" prop="number">
                <el-input
                  v-model="transferForm.number"
                  placeholder="请输入转舍数量"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="转出位置" prop="columnOut">
                <el-select
                  v-model="buildingsOutId"
                  placeholder="选择舍"
                  class="house"
                  @change="selectBuild('transferOut', buildingsOutId)"
                >
                  <el-option
                    :label="item.name"
                    :value="item.id"
                    style="width: 80px"
                    v-for="item in buildList"
                    :key="item.id"
                  ></el-option>
                </el-select>
                <el-select
                  v-model="transferForm.columnOut"
                  placeholder="栏号"
                  class="column"
                >
                  <el-option
                    :label="item.name"
                    :value="item.id"
                    v-for="item in columnList"
                    :key="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="转出猪群" prop="herdsPigsCodeOut">
                <el-select
                  v-model="transferForm.herdsPigsCodeOut"
                  placeholder="请选择猪群"
                  @change="selectHerdsPigsCodeOut"
                >
                  <el-option
                    v-for="item in buildingsOutList"
                    :key="item.id"
                    :label="item.herdsPigsCode"
                    :value="item.herdsPigsCode"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="转入位置" prop="columnIn">
                <el-select
                  v-model="buildingsInId"
                  placeholder="选择舍"
                  class="house"
                  @change="selectBuild('transferIn', buildingsInId)"
                >
                  <el-option
                    :label="item.name"
                    :value="item.id"
                    style="width: 80px"
                    v-for="item in buildList"
                    :key="item.id"
                  ></el-option>
                </el-select>
                <el-select
                  v-model="transferForm.columnIn"
                  placeholder="栏号"
                  class="column"
                >
                  <el-option
                    :label="item.name"
                    :value="item.id"
                    v-for="item in columnList1"
                    :key="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="转入猪群" prop="herdsPigsCodeIn">
                <el-autocomplete
                  class="inline-input"
                  v-model="transferForm.herdsPigsCodeIn"
                  :fetch-suggestions="querySearch"
                  placeholder="请选择猪群"
                ></el-autocomplete>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="重量">
                <el-input v-model="transferForm.weight" placeholder="输入数字">
                  <p slot="suffix" style="display: inline">kg</p></el-input
                >
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="操作人员">
                <el-select v-model="transferForm.operatorsUser">
                  <el-option
                    :label="$store.state.user.userInfo.nickName"
                    :value="userId"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="备注">
                <el-input
                  type="textarea"
                  v-model="transferForm.remark"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
      <div slot="footer">
        <el-button @click="transferDialog = false">取 消</el-button>
        <el-button type="primary" @click="confirm('transfer')">确 定</el-button>
      </div>
    </el-dialog>

    <!-- 离舍记录 -->
    <el-dialog title="登记离场" :visible.sync="leaveDialog" width="700px">
      <div>
        <el-row>
          <el-form
            ref="leaveForm"
            label-width="80px"
            :model="leaveForm"
            size="mini"
            :rules="leaveRules"
            width="700px"
          >
            <el-col :span="12">
              <el-form-item label="离场日期" prop="exitDate">
                <el-date-picker
                  value-format="yyyy-MM-dd HH:mm:ss"
                  v-model="leaveForm.exitDate"
                  type="date"
                  :picker-options="pickerOptions"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="数量" prop="number">
                <el-input
                  v-model="leaveForm.number"
                  placeholder="请输入离舍数量"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="所在位置" prop="buildingsId">
                <el-select
                  v-model="leaveForm.buildingsId"
                  placeholder="选择舍"
                  class="house"
                  @change="selectBuild('leave', leaveForm.buildingsId)"
                >
                  <el-option
                    :label="item.name"
                    :value="item.id"
                    style="width: 80px"
                    v-for="item in buildList"
                    :key="item.id"
                  ></el-option>
                </el-select>
                <el-select
                  v-model="leaveForm.columnId"
                  placeholder="栏号"
                  class="column"
                >
                  <el-option
                    :label="item.name"
                    :value="item.id"
                    v-for="item in columnList"
                    :key="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="猪群" prop="herdsPigsCode">
                <el-select
                  v-model="leaveForm.herdsPigsCode"
                  placeholder="请选择猪群"
                >
                  <el-option
                    v-for="item in leaveHerdsPigsCode"
                    :key="item.id"
                    :label="item.herdsPigsCode"
                    :value="item.herdsPigsCode"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="离场类型" prop="exitType">
                <el-select v-model="leaveForm.exitType" placeholder="选择类型">
                  <el-option label="死淘" value="死淘"></el-option>
                  <el-option label="育成" value="育成"></el-option>
                  <el-option label="转出" value="转出"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12" v-if="leaveForm.exitType === '死淘'">
              <el-form-item label="离场原因" prop="exitCause">
                <el-select v-model="leaveForm.exitCause" placeholder="选择原因">
                  <el-option
                    :label="item.label"
                    :value="item.label"
                    v-for="(item, index) in leaveCause"
                    :key="index"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="重量">
                <el-input v-model="leaveForm.weight" placeholder="输入数字"
                  ><p slot="suffix" style="display: inline">kg</p></el-input
                >
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="金额">
                <el-input v-model="leaveForm.price" placeholder="输入数字"
                  ><p slot="suffix" style="display: inline">元</p></el-input
                >
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="头单价">
                <el-input v-model="leaveForm.unitPrice" placeholder="输入数字"
                  ><p slot="suffix" style="display: inline">元</p></el-input
                >
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="操作人员">
                <el-select v-model="leaveForm.operatorsUser">
                  <el-option
                    :label="$store.state.user.userInfo.nickName"
                    :value="userId"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="备注">
                <el-input
                  type="textarea"
                  v-model="leaveForm.remark"
                  placeholder="请输入备注"
                ></el-input>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
      <div slot="footer">
        <el-button @click="leaveDialog = false">取 消</el-button>
        <el-button type="primary" @click="confirm('leave')">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import cloneDeep from "lodash/cloneDeep";
import { getColumnByBuildingsId } from "@/api/system-setup/building";
import { mixins } from "./mixin/index.js";
import { porkTableHead } from "./constant/constant.js";
import {
  pigList,
  pigEntry,
  pigMoveBuildings,
  pigLeave,
  pigDelete,
} from "@/api/production-management/pork.js";
export default {
  mixins: [mixins],
  data() {
    const number = (rule, value, callback) => {
      if (value < 0 || value == 0) {
        callback(new Error("数量必须大于0"));
      } else {
        callback();
      }
    };
    return {
      formData: {
        buildingsId: null,
        herdsPigsCode: "", //猪群号
        isPresent: "", //是否在场
        pageNum: 0,
        pageSize: 10,
      },
      entryForm: {
        isPresent: "在场",
        buildingsId: null,
        columnId: null,
        birthDate: "",
        entryDate: "",
        entryType: "",
        herdsPigsCode: "", //猪群编号
        number: null,
        operatorsUser: null,
        pageNum: 0,
        pageSize: 10,
        price: null,
        remark: "",
        startEntryTime: "",
        variety: "",
        weight: null,
      },
      transferForm: {
        buildingsId: null,
        tdDate: "",
        columnIn: null,
        columnInName: 0,
        columnOut: null,
        columnOutName: "",
        herdsPigsCodeIn: "",
        herdsPigsCodeOut: "",
        id: 0,
        ids: [],
        locationIn: "",
        locationOut: "",
        number: null,
        operatorsUser: null,
        operatorsUserName: "",
        pageNum: 0,
        pageSize: 10,
        remark: "",
        weight: 0,
      },
      entryRules: {
        entryDate: [
          {
            required: true,
            message: "请选择进场日期",
            trigger: "change",
          },
        ],
        buildingsId: [
          { required: true, message: "请选择所在位置", trigger: "change" },
        ],
        birthDate: [
          {
            required: true,
            message: "请选择出生日期",
            trigger: "change",
          },
        ],
        herdsPigsCode: [
          { required: true, message: "请输猪群编号", trigger: "change" },
        ],
        number: [
          { validator: number, trigger: "blur" },
          { required: true, message: "请输入数量", trigger: "blur" },
        ],
      },
      transferRules: {
        tdDate: [
          {
            required: true,
            message: "请选择进场日期",
            trigger: "change",
          },
        ],
        number: [
          { validator: number, trigger: "blur" },
          { required: true, message: "请输入数量", trigger: "blur" },
        ],
        columnIn: [
          { required: true, message: "请选择所在位置", trigger: "change" },
        ],
        herdsPigsCodeIn: [
          { required: true, message: "请选择转入猪群", trigger: "change" },
        ],
        columnOut: [
          { required: true, message: "请选择所在位置", trigger: "change" },
        ],
        herdsPigsCodeOut: [
          { required: true, message: "请选择转出猪群", trigger: "change" },
        ],
      },
      leaveForm: {
        buildingsId: null,
        columnId: null,
        exitCause: "",
        exitDate: "",
        exitPigType: 0,
        exitType: "",
        herdsPigsCode: "",
        ids: [],
        number: null,
        operatorsUser: null,
        pageNum: 0,
        pageSize: 10,
        price: null,
        remark: "",
        unitPrice: null,
        weight: null,
      },
      leaveRules: {
        exitDate: [
          {
            required: true,
            message: "请选择进场日期",
            trigger: "change",
          },
        ],
        number: [
          { validator: number, trigger: "blur" },
          { required: true, message: "请输入数量", trigger: "blur" },
        ],
        buildingsId: [
          { required: true, message: "请选择所在位置", trigger: "change" },
        ],
        herdsPigsCode: [
          { required: true, message: "请选择转入猪群", trigger: "change" },
        ],
        exitType: [
          { required: true, message: "请选择类型", trigger: "change" },
        ],
        exitCause: [{ required: true, message: "请选原因", trigger: "change" }],
      },
      entryHerdsPigsCodeList: [],
      herdsPigsList: [], //猪群下拉框列表
      tableList: [],
      buildingsInList: [], //转入猪群列表
      buildingsOutList: [],
      leaveHerdsPigsCode: [],
      porkTableHead,
      buildingsInId: null,
      buildingsOutId: null,
    };
  },
  created() {
    this.defaultTransferForm = cloneDeep(this.transferForm);
    this.getPorkList();
    this.selectHerdsPigsCode()
  },
  methods: {
    async getPorkList(data = this.formData) {
      let res = await pigList(data);
      if (res.code == 200) {
        this.tableList = res.data.list;
        this.total = res.data.total;
      }
    },
    //猪群下拉框列表数据
    async selectHerdsPigsCode() {
      if (this.herdsPigsList.length == 0) {
        let data = cloneDeep(this.formData);
        data.pageNum = 1;
        data.pageSize = 9999;
        let res = await pigList(data);
        if (res.code == 200) {
          res.data.list.forEach((item) => {
            this.herdsPigsList.push(item.herdsPigsCode);
          });
        }
      }
    },
    //选择栏号
    async selectBuild(type, id) {
      let res = await getColumnByBuildingsId(id);
      if (res.code == 200) {
        this.columnList = res.data;
        switch (type) {
          case "entry":
            this.entryForm.columnId = res.data[0].id;
            break;
          case "transferOut":
            this.transferForm.columnOut = res.data[0].id;
            break;
          case "transferIn":
            this.transferForm.columnIn = res.data[0].id;
            this.columnList1 = res.data;
            break;
          case "leave":
            this.leaveForm.columnId = res.data[0].id;
            break;
        }
      }
    },
    searchPorkList() {
      this.formData.pageNum = 1;
      this.getPorkList();
    },
    entryHerdsPigsCodeSearch(queryString, cb) {
      let restaurants = this.entryHerdsPigsCodeList;
      let results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      cb(results);
    },
    querySearch(queryString, cb) {
      let restaurants = this.buildingsInList;
      let results = queryString
        ? restaurants.filter(this.createFilter(queryString))
        : restaurants;
      // 调用 callback 返回建议列表的数据

      cb(results);
    },
    createFilter(queryString) {
      return (restaurant) => {
        return (
          restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) ===
          0
        );
      };
    },
    transfer() {
      this.buildingsInList = [];
      this.buildingsOutList = [];
      this.columnList = [];
      this.buildingsInId = null;
      this.buildingsOutId = null;
      this.entryForm = cloneDeep(this.defaultEntryForm);
      this.transferForm = cloneDeep(this.defaultTransferForm);
      this.$nextTick(() => {
        this.$refs.transferForm.clearValidate();
      });
      this.transferDialog = true;
    },
    confirm(type) {
      let form = `${type}Form`;
      this.$refs[form].validate(async (valid) => {
        if (valid) {
          switch (type) {
            case "entry":
              let entryRes = await pigEntry(this.entryForm);
              if (entryRes.code == 200) {
                this.entryDialog = false;
                this.formData = {
                  buildingsId: null,
                  herdsPigsCode: "", //猪群号
                  isPresent: "在场", //是否在场
                  pageNum: 1,
                  pageSize: 20,
                };
                this.getPorkList();
              }
              break;
            case "transfer":
              let transferRes = await pigMoveBuildings(this.transferForm);
              if (transferRes.code == 200) {
                this.transferDialog = false;
                this.entryForm.buildingsId = null;
                this.columnList = [];
                this.columnList1 = [];
                this.transferForm = cloneDeep(this.defaultTransferForm);
              }
              this.getPorkList();
              break;
            case "leave":
              let leaveRes = await pigLeave(this.leaveForm);
              if (leaveRes.code == 200) {
                this.leaveDialog = false;
                this.getPorkList();
              }
          }
        } else {
          return false;
        }
      });
    },
    //选择转出猪群
    async selectHerdsPigsCodeOut() {
      this.entryForm.herdsPigsCode = this.transferForm.herdsPigsCodeOut;
      let res = await pigList(this.entryForm);
      if (res.code == 200) {
        //console.log(res.data.list, res.data.list[0].id);
        this.transferForm.ids = [res.data.list[0].id];
      }
    },
    //分页器
    handlePage(val) {
      this.formData.pageNum = val.page;
      this.formData.pageSize = val.limit;
      this.getPorkList();
    },
    async deletBoar(id) {
      this.$alert("删除后猪只信息将被清空", "删除", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        showCancelButton: true,
      })
        .then(async () => {
          let res = await pigDelete(id);
          if (res.code == 200) {
            this.tableList.length > 1
              ? this.formData.pageNum
              : this.formData.pageNum--;
            this.getPorkList();
          }
        })
        .catch(() => {});
    },
  },
  watch: {
    async "transferForm.columnIn"(newValue) {
      if (newValue) {
        this.entryForm.herdsPigsCode = "";
        this.entryForm.buildingsId = this.buildingsInId;
        this.entryForm.columnId = newValue;
        let res = await pigList(this.entryForm);
        if (res.code == 200) {
          this.buildingsInList = res.data.list.map((item) => {
            return {
              value: item.herdsPigsCode,
            };
          });
        }
      }
    },
    async "entryForm.columnId"(newValue) {
      if (
        newValue &&
        newValue !== this.transferForm.columnOut &&
        newValue !== this.leaveForm.columnId
      ) {
        let res = await pigList(this.entryForm);
        if (res.code == 200) {
          this.entryHerdsPigsCodeList = res.data.list.map((item) => {
            return {
              value: item.herdsPigsCode,
            };
          });
        }
      } else {
        this.entryHerdsPigsCodeList = [];
      }
    },
    async "transferForm.columnOut"(newValue) {
      if (newValue) {
        this.entryForm.herdsPigsCode = "";
        this.entryForm.buildingsId = this.buildingsOutId;
        this.entryForm.columnId = newValue;
        let res = await pigList(this.entryForm);
        if (res.code == 200) {
          if (res.data.list.length > 0) {
            this.buildingsOutList = res.data.list;
          } else {
            this.buildingsOutList = [];
          }
        }
      }
    },
    async "leaveForm.columnId"(newValue) {
      if (newValue) {
        this.entryForm.buildingsId = this.leaveForm.buildingsId;
        this.entryForm.columnId = newValue;
        let res = await pigList(this.entryForm);
        if (res.code == 200) {
          if (res.data.list.length > 0) {
            this.leaveHerdsPigsCode = res.data.list;
          } else {
            this.leaveHerdsPigsCode = [];
          }
        }
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.el-date-editor {
  width: 160px;
}
::v-deep .house > .el-input {
  width: 90px;
}
::v-deep .column > .el-input {
  width: 70px;
}
</style>
